package com.hqj.client.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.hqj.client.entity.RoleMenu;
import com.hqj.client.mapper.RoleMenuMapper;
import com.hqj.client.service.RoleMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/5/16/016
 */
@Service
public class RoleMenuServiceImpl implements RoleMenuService {

    @Resource
    private RoleMenuMapper roleMenuMapper;
    /**
     * RoleMenu分页查询
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<RoleMenu> findPage(int page, int size){
        //QueryWrapper<RoleMenu> wrapper = new QueryWrapper<>();
        IPage<RoleMenu> findpage = roleMenuMapper.selectPage(new Page<>(page, size),null);
        return findpage.getRecords();
    }
    /**
     * 删除
     * @param id
     */
    @Override
    public int delete(Long id){
        RoleMenu roleMenu = roleMenuMapper.selectById(id);
       // roleMenu.setIsDelete(1);
       return roleMenuMapper.updateById(roleMenu);
    }
    /**
     * 修改RoleMenu
     * @param roleMenu
     */
    @Override
    public int  update(RoleMenu roleMenu) {
        return roleMenuMapper.updateById(roleMenu);
    }
    /**
     * 增加RoleMenu
     * @param roleMenu
     */
    @Override
    public int add(RoleMenu roleMenu){
       return roleMenuMapper.insert(roleMenu);
    }
    /**
     * 根据ID查询RoleMenu
     * @param id
     * @return
     */
    @Override
    public RoleMenu findById(Long id){
        return  roleMenuMapper.selectById(id);
    }
    /**
     * 查询RoleMenu全部数据
     * @return
     */
    @Override
    public List<RoleMenu> findAll() {
        return roleMenuMapper.selectList(null);
    }
}
